package dbLayer;

import java.sql.SQLException;
import java.util.ArrayList;

import modelLayer.Teacher;
import modelLayer.Class;

public interface DBClassIF {
	
	/**
	 * Inserts a new row into the database table Class. 
	 * This method uses prepared statements to sanitize our database input.
	 * 
	 * @param	name			String			the name of the class
	 * @param	grade			String			the current grade of the class
	 * @param	yearOf			String			the starting year of the class
	 * @param	ct				Teacher			class teacher as a Teacher object
	 * @return	rc				int				count of rows affected by the query execution in the database
	 */
	public int insert(String name, String grade, String yearOf, Teacher ct) throws SQLException;
	
	/**
	 * Finds a row in the database table Class.
	 * 
	 * @param	name				String			the name of the class
	 * @param	retrieveAssociation	boolean			determines if we're to retrieve 
	 * 												associations or not.
	 * @throws	Exception							throws SQL exceptions if the query isn't
	 * 												legal.
	 * @return						Class			returns the class matching the search.
	 */
	public Class find(String name, boolean retrieveAssociation);
	
	/**
	 * Finds a row in the database table Class.
	 * 
	 * @param	id					int				the id of the class
	 * @param	retrieveAssociation	boolean			determines if we're to retrieve 
	 * 												associations or not.
	 * @throws	Exception							throws SQL exceptions if the query isn't
	 * 												legal.
	 * @return						Class			returns the class matching the search.
	 */
	public Class findById(int id, boolean retrieveAssociation);
	
	/**
	 * Finds all rows in the database table Class. 
	 * 
	 * @param	retrieveAssociation	boolean			determines if we're to retrieve 
	 * 												associations or not.
	 * @throws	Exception							throws SQL exceptions if the query isn't
	 * 												legal.
	 * @return						List<Class>		returns a list of classes.
	 */	
	public ArrayList<Class> getAll(boolean retrieveAssociation);
	
	/**
	 * Updates data of a Class in the database.
	 * 
	 * @param 	cl		Class	an instance of Class to be updated
	 * @return 	rc		int		the count of rows changed in the database
	 */
	public int update(Class cl) throws SQLException;
	
	/**
	 * Deletes a row in the database.
	 * 
	 * @param 	id		int			the id of the class which is to be deleted
	 * @return 	rc		int			the count of rows changed in the database
	 * @throws 			SQLException constraint conflict
	 */
	public int remove(int id) throws SQLException;

}
